#include <bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int n,m,l,mv;

struct node{
    int p,v,a;
};

node car[N];
int p[N];
bool f[N];
int cnt[N];
vector<int> re[N],rec[N];

int calc(int po,int i){
    if(po>car[i].p) return 0;
    if(car[i].a==0){
        if(car[i].v>mv) return 1;
        else return 0;
    }
    int vv=car[i].v;
    int ss=po-car[i].p;
    int a=car[i].a;
    if(vv*vv+2*a*ss<=0) return 0;
    double v1=(double)sqrt(vv*vv+2*a*ss)*1.00;
    if(v1>(double)mv) return 1;
    else return 0;
}

void solve(){
    for(int i=0;i<N;i++) p[i]=car[i].p=car[i].v=car[i].a=f[i]=0;
    cin>>n>>m>>l>>mv;
    int ans=0;
    for(int i=1;i<=n;i++){
        cin>>car[i].p>>car[i].v>>car[i].a;
    } 
    for(int i=1;i<=m;i++) cin>>p[i];
    for(int i=1;i<=m;i++){
        for(int j=1;j<=n;j++){
            if(f[j]) continue;
            if(calc(p[i],j)){
                //cout<<p[i]<<' '<<j<<'\n';
                f[j]=1;
                cnt[i]++;
                re[i].push_back(j);
                rec[j].push_back(i);
            } 
        }
    }
    //for(int i=1;i<=n;i++) cout<<f[i]<<' ';
    for(int i=1;i<=n;i++) if(f[i]) ans++;
    int res=1000000000;
    for(int i=0;i<(1<<m);i++){
        int ff[N];
        //cout<<1<<"\n";
        for(int j=0;j<30;j++){
            int cntt=0;
            if(i&(1<<j)){
                cntt++;
                for(auto kkk:re[j+1]){
                    //cout<<kkk<<' ';
                    ff[kkk]=1;
                } 
                //cout<<'\n';
            }
            int fl=1;
            for(int k=1;k<=n;k++) if(f[k]!=ff[k]){
                //cout<<ff[i]<<' ';
                fl=0;
                break;
            }
            //cout<<'\n';
            if(fl) res=min(res,cntt);
        }
    }
    cout<<ans<<' '<<n-res<<'\n';
    return;
}

int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int T;
    cin>>T;
    while(T--) solve();
    return 0;
}